/**
 * Copyright &copy; 2012-2016
 * <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights
 * reserved.
 */
package com.thinkgem.jeesite.modules.shop.entity.info;

import java.math.BigDecimal;

import org.apache.ibatis.type.Alias;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.modules.product.entity.product.GenProduct;

/**
 * 购物订单明细配置Entity
 * 
 * @author JiangYongKang
 * @version 2016-12-19
 */
@Alias("shopOrderInfo")
public class ShopOrderInfo extends DataEntity<ShopOrderInfo> {

    private static final long serialVersionUID = 1L;
    private String name; // 商品名称
    private String code; // 商品货号
    private Double price; // 商品单价
    private BigDecimal formatPrice;
    private Long count; // 商品数量
    private Double totalAmount; // 小计
    private BigDecimal formatTotalAmount;
    private String image; // 商品图片
    private String comment; // 备注信息
    private String productId; // 商品ID
    private String orderId; //订单ID

    private GenProduct product;

    public ShopOrderInfo() {
        super();
    }

    public ShopOrderInfo(String id) {
        super(id);
    }

    @Length(min = 0, max = 64, message = "商品名称长度必须介于 0 和 64 之间")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Length(min = 0, max = 64, message = "商品货号长度必须介于 0 和 64 之间")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

	public BigDecimal getFormatPrice() {
		return new BigDecimal(getPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public void setFormatPrice(BigDecimal formatPrice) {
		this.formatPrice = new BigDecimal(getPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	@Length(min = 0, max = 10, message = "商品数量长度必须介于 0 和 10 之间")
    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }
    
    public BigDecimal getFormatTotalAmount() {
		 return new BigDecimal(getTotalAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	public void setFormatTotalAmount(BigDecimal formatTotalAmount) {
		this.formatTotalAmount  = new BigDecimal(getTotalAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
	}

	@Length(min = 0, max = 255, message = "商品图片长度必须介于 0 和 255 之间")
    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Length(min = 0, max = 255, message = "备注信息长度必须介于 0 和 255 之间")
    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Length(min = 1, max = 64, message = "商品ID长度必须介于 1 和 64 之间")
    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    @Length(min = 1, max = 20, message = "订单ID长度必须介于 1 和 20 之间")
    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public GenProduct getProduct() {
        return product;
    }

    public void setProduct(GenProduct product) {
        this.product = product;
    }

}